<?php

declare(strict_types=1);

/**
 * @Author:     Frank
 * @contact     frank_hhm@163.com
 * @Date:       2022-12-08 11:17:12
 * @Last Modified time: 2023-02-08 20:41:45
 */
namespace app\sys\controller\system;
use app\sys\controller\Base;
use think\facade\{
    App
};
use frank\utils\helper\ArrayHelper;
use app\common\services\RegionService;

/**
 * 城市数据
 * Class Region 
 * @package app\sys\controller\system
 */
class Region extends Base
{
    /**
     * Region constructor.
     * @param App $app
     * @param RegionService $service
     */
    public function __construct(App $app, RegionService $service)
    {
        parent::__construct($app);
        $this->service = $service;
    }

    /**
     * 城市数据列表
     * @noAuth(true)
     * @method(GET)
     */
    public function list(){
        $pid = $this->request->param('pid') ?? 0;
    	$this->success($this->service->getSubDataByPid($pid));
    }

    /**
     * 城市数据列表
     * @noAuth(true)
     * @method(GET)
     */
    public function treeList(){
        $this->success(['tree'=>$this->service->getCacheTree(),'count'=>$this->service->getCacheCounts()]);
    }

    /**
     * 城市联级数据
     * @noAuth(true)
     * @method(GET)
     */
    public function getCascaderRegion(){
        $this->success($this->service->getCascaderRegion());
    }
}
